from typing import List

class Solution:
    def canJump(self, nums: List[int]) -> bool:
        i, j = 0, nums[0]
        max_leap = nums[0]
        while j < len(nums) - 1 and max_leap != 0:
            leaps = [num + k for k, num in enumerate(nums[i:j+1])]
            max_leap = max(leaps)
            i, j = j, i + max_leap
        return j >= len(nums) - 1

if __name__ == '__main__':
    s = Solution()
    s.canJump([2,3,1,1,4])
    s.canJump([3,2,1,0,4])
